package com.eric.server.UI;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class DemoUI extends JFrame {
    JButton btn ;
    JScrollPane scrollPane;
    JTextArea textArea;

    public void initUI(){
        btn = new JButton("跳转");
        btn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textArea.setCaretPosition(textArea.getDocument().getLength());
            }
        });
        this.getContentPane().add(btn,BorderLayout.SOUTH);
        this.getContentPane().add(scrollPane = new JScrollPane(textArea = new JTextArea()), BorderLayout.CENTER);
    }

    public static void main(String [] s){
        DemoUI ui = new DemoUI();
        ui.initUI();
        ui.setSize(300,300);
        ui.setVisible(true);
        ui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
